package com.generalbackend.controller;

import com.generalbackend.common.annotion.ApiPermission;
import com.generalbackend.common.enums.MenuEnum;
import com.generalbackend.common.model.CommonResult;
import com.generalbackend.common.model.query.UpdateLoginBackgroundPictureQuery;
import com.generalbackend.common.service.ISystemConfigurationService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统配置信息
 * @author tim.xie
 * @date 2022/7/12 15:40
 */
@Slf4j
@RestController
@RequestMapping(value = "/api/systemConfig")
public class SystemConfigurationController {

    @Autowired
    private ISystemConfigurationService systemConfigurationService;

    @ApiOperation(httpMethod = "GET", value = "获取登录页面背景图片")
    @ApiPermission(name = "获取登录页面背景图片", isCommon = true, menu = {MenuEnum.SystemConfiguration})
    @RequestMapping(value = "/getLoginBackgroundPicture", method = RequestMethod.GET)
    public CommonResult getLoginBackgroundPicture() {
        return CommonResult.successCommonResult(systemConfigurationService.getLoginBackgroundPicture(), "查询成功");
    }

    @ApiOperation(httpMethod = "POST", value = "修改登录页面背景图片")
    @ApiPermission(name = "修改登录页面背景图片", menu = {MenuEnum.SystemConfiguration})
    @RequestMapping(value = "/updateLoginBackgroundPicture", method = RequestMethod.POST)
    public CommonResult updateLoginBackgroundPicture(@RequestBody UpdateLoginBackgroundPictureQuery updateLoginBackgroundPictureQuery) {
        systemConfigurationService.updateLoginBackgroundPicture(updateLoginBackgroundPictureQuery);
        return CommonResult.successCommonResult("修改成功");
    }

}
